﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;

namespace CartoonViewer
{
    public class ListPanel:Grid,IPanelList
    {
        public ListPanel()
            : base()
        {
            this.ColumnCount = 19;
            initData();
        
        }

        public ListPanel(int _columnCount):this()
        {
            this.ColumnCount = _columnCount;
        }
        
        protected void initData()
        {
            this.RowDefinitions.Clear();
            this.ColumnDefinitions.Clear();
            

            this.RowDefinitions.Add(new RowDefinition());
            for (int i = 0; i < this.ColumnCount; i++)
            {
                this.ColumnDefinitions.Add(new ColumnDefinition());
            }

            this.P_Top = this.P_Left = 0;
            this.Margin_Top = this.Margin_Left = 5;
        }


        public virtual void Clear()
        {
            this.Children.Clear();
            
            initData();
        }

         


        public double P_Top
        {
            get;
            set;
        }

        public double P_Left
        {
            get;
            set;
        }

        public double Margin_Top
        {
            get;
            set;
        }

        public double Margin_Left
        {
            get;
            set;
        }

        public int ColumnCount
        {
            get;
            set;
        }

        public int RowNum
        {
            get
            {
                int reVal = 1;
                reVal = (this.Children.Count-1) / this.ColumnCount;
                return reVal;
            }
        }

        public int ColumnNum
        {
            get
            { 
                int reVal = 1;
                reVal = (this.Children.Count-1) % this.ColumnCount;
                return reVal;
            }
        }
 
    }
}
